//
class Animal {
    //父类
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println(this.name+"正在吃......");
    }

}
class Dog extends Animal {
    //子类Dog
    public String color;

    public Dog(String name,int age,String color) {
        super(name,age);
        this.color = color;
    }
    public void eat() {
        System.out.println(this.name+"正在吃狗粮");
    }
    public void bark() {
        System.out.println(this.name+"正在汪汪汪......");
    }

}
class Bird extends Animal {

    public Bird(String name,int age) {
        super(name,age);
    }
    public void eat() {
        System.out.println(this.name+"正在吃鸟粮");
    }
    public void fly() {
        System.out.println(this.name+"正在飞.......");
    }

}
public class Test1 {

    public static void main(String[] args) {
        //向下转型




    }
    public static void fun(Animal animal) {//第二种向上转型
        animal.eat();//多态
    }
    public static Animal fun2() {//第三种向上转型
        return new Dog("旺财",3,"黄色");
    }
    public static void main3(String[] args) {
        //多态演示，向上转型
        Dog dog = new Dog("旺财",3,"黄色");
        fun(dog);

        Bird bird = new Bird("布谷",3);
        fun(bird);

    }
    public static void main2(String[] args) {
        //动态绑定，向上转型
        Dog dog = new Dog("旺财",3,"白色");
        Animal animal = dog;
        animal.eat();
    }
    public static void main1(String[] args) {
        //复习继承
        Dog dog = new Dog("旺财",3,"白色");
        dog.eat();
        dog.bark();
    }
}
